/**
 * @file 状态管理入口
 * @description 初始化Pinia状态管理并导出所有store
 * @date 2024-06-10
 */

import { createPinia } from 'pinia'
import { createPiniaPersist } from './plugins/persist'

// 导入所有模块
import { useTrackStore } from './modules/track'
import { useDeviceStore } from './modules/device'
import { useMapStore } from './modules/map'

// 统一导出
export {
  useTrackStore,
  useDeviceStore,
  useMapStore
}

/**
 * 初始化Pinia实例
 * @returns Pinia实例
 */
export function createAppPinia() {
  const pinia = createPinia()
  
  // 添加持久化插件
  pinia.use(createPiniaPersist({
    prefix: 'gps-',  // 存储键前缀
  }))
  
  return pinia
}

/**
 * 初始化所有 store
 */
export function setupStore() {
  // 初始化各store模块
  const trackStore = useTrackStore()
  const deviceStore = useDeviceStore()
  const mapStore = useMapStore()
}

export * from './modules/track'
export * from './modules/device'
export * from './modules/map' 